package org.zjt.hessian.demo.client;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.caucho.HessianProxyFactoryBean;
import org.zjt.hessian.demo.common.service.HelloService;

/**
 * 加载远程 hessian rpc 的IOC容器。
 */
@EnableConfigurationProperties
@Configuration
public class HessianFactoryBeanConfig {

    private String serverUrl = "http://localhost:7808/HelloService";

    /**
     * 得到远程的hessian的IOC容器（Bean Factory）
      */
    @Bean
    public HessianProxyFactoryBean helloClient() {
        HessianProxyFactoryBean factory = new HessianProxyFactoryBean();
        factory.setServiceUrl(serverUrl);
        factory.setServiceInterface(HelloService.class);
        return factory;
    }

}
